#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode Node;
struct ListNode* removeElements(struct ListNode* head, int val) {
    Node* newhead = NULL;
    Node* newtail = NULL;
    Node* cur = head;
    while (cur)
    {
        if (cur->val != val)
        {
            if (newhead == NULL)
            {
                newtail = newhead = cur;
            }
            else
            {
                newtail->next = cur;
                newtail = newtail->next;
            }
        }
        cur = cur->next;
    }
    if (newtail)
    {
        newtail->next = NULL;
    }
    return newhead;
}


/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode Node;
struct ListNode* middleNode(struct ListNode* head) {
    Node* fast = head;
    Node* slow = head;
    while (fast && fast->next)
    {
        fast = fast->next->next;
        slow = slow->next;
    }
    return slow;
}

int main()
{

	return 0;
}